package com.ydsungan.serviceimpl;

import com.ydsungan.bean.Signin;
import com.ydsungan.dao.SigninDao;
import com.ydsungan.daoimpl.SigninDaoImpl;
import com.ydsungan.service.SigninService;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

public class SigninServiceImpl implements SigninService {

    SqlSessionFactory sqlSessionFactory = null;
    private SigninDao signinDao = null;

    public SigninServiceImpl() throws IOException {
        //获取sqlSessionFactory对象
        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");
        sqlSessionFactory = builder.build(inputStream);
        signinDao = new SigninDaoImpl(this.sqlSessionFactory);
    }

    @Override
    public List<Signin> getSigninByMap(Map<String, Object> map) {
        return signinDao.getSigninByMap(map);
    }
    @Override
    public void addSignin(Signin signin) {
        signinDao.addSignin(signin);
    }

    @Override
    public void deleteById(Integer id) {
        signinDao.deleteById(id);
    }
}
